package br.inatel.wiiproject.view;
import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class MainFrame extends JFrame {

	private static final long serialVersionUID = 1L;
	private RemotePanel rightRemotePanel = null;
	private RemotePanel leftRemotePanel = null;
	private RemotePanel rightNunchukPanel = null;
	private RemotePanel leftNunchukPanel = null;
	private static int width = 800;
	private static int heigth = 600;
	private static MainFrame frame = null;	

	private MainFrame() {
		super("Accelerometer graph: Luistxt");
		JPanel panel = new JPanel(new GridLayout(2,2));
		rightRemotePanel = new RemotePanel(1);
		leftRemotePanel = new RemotePanel(3);
		rightNunchukPanel = new RemotePanel(2);
		leftNunchukPanel = new RemotePanel(4);
		panel.add(new TitledPanel("Right Remote Panel", rightRemotePanel));
		panel.add(new TitledPanel("Left Remote Panel", leftRemotePanel));
		panel.add(new TitledPanel("Right Nunchuk Panel", rightNunchukPanel));
		panel.add(new TitledPanel("Left Nunchuk Panel", leftNunchukPanel));
		panel.setSize(width,heigth);
		this.setSize(width,heigth);
		this.setContentPane(panel);
		this.setResizable(true);
		this.setVisible(true);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	public static MainFrame getInstance(){
		if (frame == null){
			frame = new MainFrame();
		}
		return frame;
	}
	
	public RemotePanel getRightRemotePanel() {
		return rightRemotePanel;
	}
	
	public RemotePanel getRightNunchukPanel() {
		return rightNunchukPanel;
	}
	
	public RemotePanel getLeftRemotePanel() {
		return leftRemotePanel;
	}
	
	public RemotePanel getLeftNunchukPanel() {
		return leftNunchukPanel;
	}
}
